package i_thread;

// Thread  synchronized Example
// make : pwg
// date : 2003
// note :  동기화 구현
// ============================================

// 공유 정보 클래스
class threadDATA {
	int result = 0;

	synchronized public void hap() {
		int i = 0;
		for (i = 1; i <= 10; i++) {
			result += i;
			System.out.println(result);
			for (int j = 0; j < 30000000; j++) {
			}
		}
		System.out.println("");
	}

}

public class ThreadSyncEx extends Thread {
	String msg;
	threadDATA data;

	public ThreadSyncEx(String a, threadDATA d) {
		msg = a;
		data = d;
	}

	public void run() {
		data.hap();
	}

	public static void main(String args[]) {
		threadDATA resource = new threadDATA();
		Thread t1 = new ThreadSyncEx("step 1 = ", resource);
		Thread t2 = new ThreadSyncEx("step 2 = ", resource);

		t1.start();
		t2.start();

	}

};
